cmake_minimum_required(VERSION 3.5)
project(sensor)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 17)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -g)
endif()


# Debug RelWithDebInfo MinSizeRel
set(CMAKE_BUILD_TYPE Release)

include_directories(include) 

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp_components REQUIRED)
find_package(rclcpp REQUIRED)
find_package(interface REQUIRED)
find_package(common REQUIRED)
find_package(OpenCV REQUIRED)
find_package(cv_bridge REQUIRED)
#find_package(CUDA REQUIRED)

include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${CUDA_INCLUDE_DIRS})

file(GLOB camera_src "camera_component/*.cpp")
add_library(camera_component SHARED  ${camera_src})
ament_target_dependencies(camera_component rclcpp interface common cv_bridge)
#target_link_libraries(camera_component ${OpenCV_LIBS} ${CUDA_LIBRARIES} ${CUDA_nppicc_LIBRARY})
target_link_libraries(camera_component ${OpenCV_LIBS})
rclcpp_components_register_nodes(camera_component "sensor::camera::CameraComponent")

file(GLOB radar_src "radar_component/*.cpp" "radar_component/ziyan/*.cpp" "radar_component/ziyan/*.c" "radar_component/nezha/*.c" "radar_component/nezha/*.cpp")
add_library(radar_component SHARED  ${radar_src})
ament_target_dependencies(radar_component rclcpp interface common)
target_link_libraries(radar_component)
rclcpp_components_register_nodes(radar_component "sensor::radar::RadarComponent")

file(GLOB gps_src "gps_component/*.cpp" "gps_component/f9k/*.cpp" "gps_component/serial_port/*.cpp")
add_library(gps_component SHARED  ${gps_src})
ament_target_dependencies(gps_component rclcpp interface common)
#target_link_libraries(camera_component ${OpenCV_LIBS} ${CUDA_LIBRARIES} ${CUDA_nppicc_LIBRARY})
target_link_libraries(gps_component ${OpenCV_LIBS})
rclcpp_components_register_nodes(gps_component "sensor::gps::GpsComponent")

include(../common/cmake/add3rd.cmake)
add3rds(utils muduo)

add_executable(sensor main.cpp)
ament_target_dependencies(sensor rclcpp rclcpp_components) 
target_link_libraries(sensor camera_component radar_component gps_component muduo_net muduo_base)
install(TARGETS sensor camera_component radar_component gps_component
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  # the following line skips the linter which checks for copyrights
  # uncomment the line when a copyright and license is not present in all source files
  #set(ament_cmake_copyright_FOUND TRUE)
  # the following line skips cpplint (only works in a git repo)
  # uncomment the line when this package is not in a git repo
  #set(ament_cmake_cpplint_FOUND TRUE)
  ament_lint_auto_find_test_dependencies()
endif()

ament_package()
